
//  1
var arr=[1,2,3,4];
console.log(arr.indexOf(3));

//  2
var arr1=[1,2,3,4];
var sum=0;
for(var i=0;i<arr1.length;i++){
    sum=sum+arr1[i]
}
console.log(sum);

//  3
var arr3=[1,2,3,4,2];
for(k=0;k<arr3.length;k++){
    for(j=0;j<arr3.length;j++){
        if(arr3[i]==2){
            arr3.splice(arr3.indexOf(i),1);
        }
    }
}
console.log(arr3);


//  4
var arr4=[1,2,2,3,4,2,2];
for(i=0;i<arr4.length;i++){
    if(arr4[i]==2){

        arr4.splice(arr4.indexOf(i)+1,1);
    }
}
console.log(arr4);


//  5
var arr5=[1,2,3,4];
arr5.push(10)
console.log(arr5);

//  6
var arr6=[1,2,3,4];
arr6.reverse();
arr6.shift();
arr6.reverse();
console.log(arr6);

//  7
var arr7=[1,2,3,4];
arr7.unshift(10);
console.log(arr7);

//  8
var arr8=[1,2,3,4];
arr8.splice(0,1);
console.log(arr8);

//  9
var arr9=[1,2,3,4];
var aaa=arr9.concat(['a','b','c',1]);
console.log(aaa);


//  10
var arr10=[1,2,3,4];
arr10.splice(2,0,'z');
console.log(arr10);

//  11
var arr11=[1, 2, 4, 4, 3, 4, 3];
var k=0;
for(i=0;i<arr11.length;i++){
    if(arr11[i]==4){
        k++
    }
}
console.log(k);

//  12
var arr12=[1, 2, 4, 4, 3, 3, 1, 5, 3];
function isre(arr12){
   var a =[];
    for(var i = 0;i<arr12.length;i++){
        if(arr.indexOf(arr12[i]) != -1 && arr12.indexOf(arr[i]) != arr12.lastIndexOf(arr[i])){
            a.push(arr12[i]);
        }
    }
    return a;
}
console.log(isre(arr12));

//13
var arr13= [1, 2, 3, 4];
function pf(arr13){
    var a =[];
    for(var i = 0;i<arr13.length;i++){
        a.push(arr13[i]*arr13[i]);
    }
    return a;
}
console.log(pf(arr13));


//14
var arr14='abcdefabc';
function allre(arr,item){
    var a = [];
    var rest =[];
    for(var i =0;i<arr.length;i++){
        a[0] = arr[i];
        var isre = a.indexOf(item);
        if(isre != -1){
        rest.push(i);
        }
    }
    return rest;
}
console.log(allre(arr1,1));

